package com.atguigu.juc.study.chapter12.syncup;

/**
 * @author : leimingchao
 * @date Date : 2022年06月20日 21:23
 */
public class Ticket {

    private int number = 50;

    Object object = new Object();

    public void sale() {

        synchronized (object) {
            if (number > 0) {
                System.out.println(Thread.currentThread().getName() + "卖出第：\t" + (number--) + "\t还剩下：" + number);
            }
        }
    }
}
